package com.tangyuan.algorithm;

import org.springframework.stereotype.Component;

import java.util.*;

/**权重票选
 * @author xiao
 */
@Component
public class Vote {

    /**
     * 权重处理方法
     * @param A 权重3
     * @param B 权重4
     * @param C 权重5
     * @author xiao
     * @return 权重排行后的电影id
     */
    public List<Long> voteResult(List<Long> A,List<Long> B,List<Long> C){
        Map<Long, Integer> voteMap = new HashMap<>();
        for (long id : A) {
            voteMap.put(id, 3);
        }
        for (long id : B) {
            voteMap.put(id, voteMap.getOrDefault(id, 0) + 4);
        }
        for (long id : C) {
            voteMap.put(id, voteMap.getOrDefault(id, 0) + 5);
        }
        List<Long> sortedIds = new ArrayList<>(voteMap.keySet());
        sortedIds.sort((id1, id2) -> voteMap.get(id2) - voteMap.get(id1));
        return sortedIds;
    }






}
